#include "Tile.hpp"

using namespace sf;

//Constructor(s)

Tile::Tile()
{

}

//Getter(s)

Sprite& Tile::get_tileSprite()
{
	return tileSprite;
}

int Tile::get_type() const
{
	return type;
}

//Setter(s)

void Tile::set_type(int p_type)
{
	type = p_type;
}

//Other(s)

void Tile::initTile(Vector2f p_position, Image &p_img, int p_num)
{
	int x(0), y(0), nbTile(p_img.GetWidth()/TILE_SIZE.x);

	while(p_num > nbTile - 1)
	{
		y++;
		p_num -= nbTile;
	}

	x = p_num;

	tileSprite.SetImage(p_img);
	tileSprite.SetSubRect(IntRect(x*TILE_SIZE.x, y*TILE_SIZE.y, x*TILE_SIZE.x+TILE_SIZE.x, y*TILE_SIZE.y+TILE_SIZE.y));
	tileSprite.SetPosition(p_position);
}

void Tile::clearSprite()
{
	tileSprite.SetColor(Color::Black);
}